package com.study.spring.createBean;

import com.study.spring.common.Person;
import com.study.spring.config.SpringConfig;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTest {


    @Test
    public void test() {

//        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
//        User user = (User) applicationContext.getBean("user");
//        user.add();

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
//        Object person = context.getBean(Person.class);
//        System.out.println(person);
//        Object boss = context.getBean("boss");
//        System.out.println(boss);

         String[] beanDefinitionNames = context.getBeanDefinitionNames();

        for (String s:beanDefinitionNames) {
            System.out.println(s);
        }
//        Person person = context.getBean(Person.class);
//
//        System.out.println(person);


        //System.out.println(context.getBean("person"));
        context.close();


    }
}



